<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!--右侧-->
<div class="realR_right">

	<div class="box mb10">
		<div class="tit">通知</div>
		<div class="con" id="noMsg">没有新消息</div>
		<div class="con" id="notiType1" style="display:none;">
			<a id="num1"
				href="${pageContext.request.contextPath}/notification/noticeIndex.action?type=1"></a>
		</div>
		<div class="con" id="notiType2" style="display:none;">
			<a id="num2" href="#"></a>
		</div>
	</div>

</div>

<script type="text/javascript">
	window.setInterval("polling()", 2000);
	function polling() {
		$
				.ajax({
					type : "post", // 请求方式为POST，避免乱码问题
					url : "${pageContext.request.contextPath}/notification/queryNewNotification.action", // 发送请求地址
					data : { // 发送给数据库的数据
						ajax : "true"
					},
					dataType : "json", // 接收的数据格式为JSON，如果不指定则自动检测
					success : function(jsondata, textStatus) {
						var numOfAllNewNotification = jsondata["numOfAllNewNotification"];
						var numOfNewNotificationT1 = jsondata["numOfNewNotificationT1"];
						var numOfNewNotificationT2 = jsondata["numOfNewNotificationT2"];
						if (numOfAllNewNotification != 0) {
							if (!$("#notiType1").is(":visible")) {
								$("#noMsg").slideToggle("fast");
							}
							if (numOfNewNotificationT1 != 0
									&& $("#notiType1").is(":hidden")) {
								$("#notiType1").slideToggle("fast");
								$("#num1").text(
										"您有" + numOfNewNotificationT1
												+ "条新的应标邀请");
							}
							if (numOfNewNotificationT2 != 0
									&& $("#notiType2").is(":hidden")) {
								$("#notiType2").slideToggle("fast");
								$("#num2").text(
										"您有" + numOfNewNotificationT2
												+ "条新的交易提醒");
							}

						}
					}
				});
		//alert(notification.text());
	}
</script>
